;(function () {
  new Vue({
    el:'.lc-data-list',
    data:{
      quanxian: JSON.parse(window.localStorage.getItem('permissions')),
      isShowAllChange: false,
      pageLimitData: [{name: '10', code: '10'}, {name: '15', code: '15'}, {name: '20', code: '20'}],
      listMenu: [
        {
          'name':'真实源',
          'code':'REAL'
        },
        {
          'name':'配置源',
          'code':'CONFIG'
        },
      ],
      activitylistMenu: [
        {
          'name':'配置源',
          'code':'CONFIG'
        },
      ],
      activityCenterMenu:[
        {
          'name':'活动分析',
          'code':'ACTIVITY_COUNT'
        },
        {
          'name':'活动列表',
          'code':'ACTIVITY_LIST'
        },
      ],
      selectedAllType:['REAL'],
      starProject:{
        selectedStarProject:['REAL'],
        listData:[],
      },
      placeMes:{
        selectedPlaceMes:['REAL'],
        listData:[],
        pageLimit:5,
        currentPage:1,
        totalCount:0,
        teamMemberCount:0,
        financingAmount:0,
        publicService:[]
      },
      investmentFinancing:{
        selectedItem:['REAL'],
        investmentFinancingAim1:0,
        investmentFinancingAim2:0,
        investmentFinancingAim3:0,
        investmentFinancingAim4:0,
      },
      activityCenter:{
        count1:0,
        count2:0,
        count3:0,
      },
      activity:{
        selectedType:['ACTIVITY_COUNT'],
        selectedItem:['CONFIG'],
        listData:[],
        pageLimit:5,
        currentPage:1,
        totalCount:0,
      },
      company:{
        selectedItem:['REAL'],
        industryListData:[],
        smallTypeListData:[],
        bigTypeListData:[],
      },
      companyDetails:{
        selectedItem:['REAL'],
        dvptAchievementsAmount1:0,
        dvptAchievementsAmount2:0,
        dvptAchievementsAmount3:0
      }
    },
    filters:{
      formatDate:function (item) {
        return hlDateUtil.formatUTCDate(item)
      },
      formatUndefined:function (item) {
        if(item == undefined)return '--'
        return item
      }
    },
    methods:{
      // 获取配置源头字典
      getConfigDict(){
        let self = this
        hlhttp.get({
          url: 'configure/dict',
          data: {module_code: 'ZUKN', config_name: 'ZK_DATAV_SOURCE_TYPE_SHOW', parent_dict_code: '#' , key: '#'},
          success(res){
            res.forEach(el => {
              if(el.dictCode == 'PROJECT_SHOW_SOURCE_TYPE') self.starProject.selectedStarProject = [el['dictValue']]
              if(el.dictCode == 'SPACE_INFO_SOURCE_TYPE') self.placeMes.selectedPlaceMes = [el['dictValue']]
              if(el.dictCode == 'INVESTMENT_FINANCING_DOCKING_SOURCE_TYPE') self.investmentFinancing.selectedItem = [el['dictValue']]
              if(el.dictCode == 'ENTRY_COMPANY_ANALYSIS_SOURCE_TYPE') self.company.selectedItem = [el['dictValue']]
              if(el.dictCode == 'COMPANY_DEVELOPMENT_ACHIEVEMENTS_SOURCE_TYPE') self.companyDetails.selectedItem = [el['dictValue']]
            })

            self.getStarProjectListData()
            self.getPlaceMesDetailsData()
            self.getPlaceMesListData()
            self.getInvestmentDetailsData()
            self.getCompanyListData()
            self.getSmallTypeListData()
            self.getBigTypeListData()
            self.getCompanyDetailsData()
            self.getActivityListData()
            self.getActivityCenterData()
          }
        })
      },
      // 获取活动中心字典
      getActivityCenterDict(){
        let self = this
        hlhttp.get({
          url: 'configure/dict',
          data: {module_code: 'ZUKN', config_name: 'ZK_DATAV_SOURCE_ACTIVITY_MODULE_TYPE', parent_dict_code: '#' , key: '#'},
          success(res){
            res.forEach(el => {
              self.activity.selectedType = [el['dictValue']]
            })
          }
        })
      },
      // 编辑配置源头字典
      editConfigDict(dictCode,dictName,dictValue){
        let self = this
        let data = {
          'module_code': 'ZUKN',
          'config_name': 'ZK_DATAV_SOURCE_TYPE_SHOW',
          'dict_code': dictCode,
          'dict_name': dictName,
          'dict_value': dictValue,
          'dict_display_name': '#',
          'dict_property': '#',
          'default_flag': 'N',
          'config_type': 'BASE_VALUE'
        }

        hlhttp.put({
          url: 'configure/tenant_dict_config',
          data: data,
          success(res){

          }
        })
      },
      // 编辑活动中心字典
      editActivityCenterDict(dictCode,dictName,dictValue){
        let self = this
        let data = {
          'module_code': 'ZUKN',
          'config_name': 'ZK_DATAV_SOURCE_ACTIVITY_MODULE_TYPE',
          'dict_code': dictCode,
          'dict_name': dictName,
          'dict_value': dictValue,
          'dict_display_name': '#',
          'dict_property': '#',
          'default_flag': 'N',
          'config_type': 'BASE_VALUE'
        }

        hlhttp.put({
          url: 'configure/tenant_dict_config',
          data: data,
          success(res){

          }
        })
      },
      // 获取场地信息
      getPlaceDict(){
        let self = this
        hlhttp.get({
          url: 'configure/dict',
          data: {module_code: 'ZUKN', config_name: 'ZK_SPACE_CONFIG_TYPE', parent_dict_code: '#' , key: '#'},
          success(res){
            res.forEach(el => el['val'] = el['dictName'])
            if(!self.placeMes.publicService.length) self.placeMes.publicService = res
          }
        })
      },
      selectStarPro(curItem){
        const self = this
        const text = curItem[0] == 'REAL' ? '真实源' : '配置源'

        hllayer.confirm1('切换至' + text + '？确认后实时生效',
            function () {
              self.getStarProjectListData()
              self.editConfigDict('PROJECT_SHOW_SOURCE_TYPE','优质项目展示源类型：REAL 真实源，CONFIG 配置源',curItem[0])
            },
            function () {
              self.starProject.selectedStarProject = curItem[0] == 'REAL' ? ['CONFIG'] : ['REAL']
            },
            function () {
              self.starProject.selectedStarProject = curItem[0] == 'REAL' ? ['CONFIG'] : ['REAL']
            },
        )
      },
      selectPlaceMes(curItem){
        const self = this
        const text = curItem[0] == 'REAL' ? '真实源' : '配置源'

        hllayer.confirm1('切换至' + text + '？确认后实时生效',
            function () {
              self.getPlaceMesListData()
              self.getPlaceMesDetailsData()
              self.editConfigDict('SPACE_INFO_SOURCE_TYPE','场地信息源类型：REAL 真实源，CONFIG 配置源',curItem[0])
            },
            function () {
              self.placeMes.selectedPlaceMes = curItem[0] == 'REAL' ? ['CONFIG'] : ['REAL']
            },
            function () {
              self.placeMes.selectedPlaceMes = curItem[0] == 'REAL' ? ['CONFIG'] : ['REAL']
            },
        )
      },
      selectInvestmentFinancingList(curItem){
        const self = this
        const text = curItem[0] == 'REAL' ? '真实源' : '配置源'

        hllayer.confirm1('切换至' + text + '？确认后实时生效',
            function () {
              self.getInvestmentDetailsData()
              self.editConfigDict('INVESTMENT_FINANCING_DOCKING_SOURCE_TYPE','投融资对接源类型：REAL 真实源，CONFIG 配置源',curItem[0])
            },
            function () {
              self.investmentFinancing.selectedItem = curItem[0] == 'REAL' ? ['CONFIG'] : ['REAL']
            },
            function () {
              self.investmentFinancing.selectedItem = curItem[0] == 'REAL' ? ['CONFIG'] : ['REAL']
            },
        )

      },
      selectActivityMenuList(){
        this.getActivityListData()
      },
      selectActivityCenterList(curItem){
        console.log(curItem);
        this.editActivityCenterDict('HZLC_CODE','模块展示类型，ACTIVITY_COUNT 活动统计信息，ACTIVITY_LIST 活动列表',curItem[0])
      },
      selectCompanyMenuList(curItem){
        const self = this
        const text = curItem[0] == 'REAL' ? '真实源' : '配置源'

        hllayer.confirm1('切换至' + text + '？确认后实时生效',
            function () {
              self.getCompanyListData()
              self.getSmallTypeListData()
              self.getBigTypeListData()
              self.editConfigDict('ENTRY_COMPANY_ANALYSIS_SOURCE_TYPE','入驻企业分析源类型：REAL 真实源，CONFIG 配置源',curItem[0])
            },
            function () {
              self.company.selectedItem = curItem[0] == 'REAL' ? ['CONFIG'] : ['REAL']
            },
            function () {
              self.company.selectedItem = curItem[0] == 'REAL' ? ['CONFIG'] : ['REAL']
            },
        )

      },
      selectCompanyDetailsMenuList(curItem){
        const self = this
        const text = curItem[0] == 'REAL' ? '真实源' : '配置源'

        console.log(curItem[0]);

        hllayer.confirm1('切换至' + text + '？确认后实时生效',
            function () {
              self.getCompanyDetailsData()
              self.editConfigDict('COMPANY_DEVELOPMENT_ACHIEVEMENTS_SOURCE_TYPE','企业发展成果源类型：REAL 真实源，CONFIG 配置源',curItem[0])
            },
            function () {
              self.companyDetails.selectedItem = curItem[0] == 'REAL' ? ['CONFIG'] : ['REAL']
            },
            function () {
              self.companyDetails.selectedItem = curItem[0] == 'REAL' ? ['CONFIG'] : ['REAL']
            },
        )
      },
      goPage: function () {
        hlUrlUtil.goTo('lcPlaceConfig', {ddtab:true})
      },
      getStarProjectListData() {
        let self = this;
        let data = {
          source_type: self.starProject.selectedStarProject.length ? self.starProject.selectedStarProject[0] : '#',
        }

        hlhttp.get({
          url:'datav_source/project_show/_search',
          data: data,
          success(data){
            if(data.length == 0) return
            self.starProject.listData = data
          }
        })
      },
      // 获取场地信息列表数据
      getPlaceMesListData() {
        let self = this;
        let data = {
          source_type: self.placeMes.selectedPlaceMes.length ? self.placeMes.selectedPlaceMes[0] : '#',
          page: self.placeMes.currentPage,
          limit: self.placeMes.pageLimit,
        }

        hlhttp.get({
          url:'datav_source/space_area_analysis/_search',
          data: data,
          success(data){
            if(data.data.length == 0) return
            self.placeMes.listData = data.data
            self.placeMes.totalCount = data.totalCount
            self.placeMes.totalPage = data.totalPage
          }
        })
      },
      // 获取场地信息详情数据
      getPlaceMesDetailsData() {
        let self = this;
        let data = {
          source_type: self.placeMes.selectedPlaceMes.length ? self.placeMes.selectedPlaceMes[0] : '#',
        }

        hlhttp.get({
          url:'datav_source/space_count',
          data: data,
          success(data){
            self.placeMes.count = data.count
            self.placeMes.totalAcreage = data.totalAcreage
            self.placeMes.publicService = data.publicService ? data.publicService : []
          }
        })
      },
      // 获取场地信息详情数据
      getInvestmentDetailsData() {
        let self = this;
        let data = {
          source_type: self.investmentFinancing.selectedItem.length ? self.investmentFinancing.selectedItem[0] : '#',
        }

        hlhttp.get({
          url:'datav_source/investment_financing_docking',
          data: data,
          success(data){
            self.investmentFinancing.investmentFinancingAim1 = data.investmentFinancingActual1
            self.investmentFinancing.investmentFinancingAim2 = data.investmentFinancingActual2
            self.investmentFinancing.investmentFinancingAim3 = data.investmentFinancingActual3
            self.investmentFinancing.investmentFinancingAim4 = data.investmentFinancingActual4
          }
        })
      },
      // 获取活动中心详情
      getActivityCenterData(){
        let self = this;
        let data = {}

        hlhttp.get({
          url:'datav_source/activity_count',
          data: data,
          success(data){
            self.activityCenter.count1 = data.activityCenterCount1
            self.activityCenter.count2 = data.activityCenterCount2
            self.activityCenter.count3 = data.activityCenterCount3
          }
        })
      },
      // 获取活动列表数据
      getActivityListData() {
        let self = this;
        let data = {
          source_type: 'CONFIG',
          page: self.activity.currentPage,
          limit: 5,
        }

        hlhttp.get({
          url:'datav_source/activity_info/_search',
          data: data,
          success(data){
            if(data.data.length == 0) return
            self.activity.listData = data.data
            self.activity.totalCount = data.totalCount
          }
        })
      },
      // 获取企业发展成果列表
      getCompanyListData() {
        let self = this;
        let data = {
          source_type: self.company.selectedItem.length ? self.company.selectedItem[0] : '#',
          page: 1,
          limit: 1000,
        }

        hlhttp.get({
          url:'datav_source/company_industry_analysis/_search',
          data: data,
          success(data){
            self.company.industryListData = data.data
          }
        })
      },
      // 获取团队类别分析列表
      getSmallTypeListData() {
        let self = this;
        let data = {
          source_type: self.company.selectedItem.length ? self.company.selectedItem[0] : '#',
          analysis_type: 'WAREHOUSE_PROJECT1',
          page: 1,
          limit: 1000,
        }

        hlhttp.get({
          url:'datav_source/team_type_analysis/_search',
          data: data,
          success(data){
            self.company.smallTypeListData = data.data
          }
        })
      },
      // 获取团队类别分析列表
      getBigTypeListData() {
        let self = this;
        let data = {
          source_type: self.company.selectedItem.length ? self.company.selectedItem[0] : '#',
          analysis_type: 'WAREHOUSE_PROJECT2',
          page: 1,
          limit: 1000,
        }

        hlhttp.get({
          url:'datav_source/team_type_analysis/_search',
          data: data,
          success(data){
            self.company.bigTypeListData = data.data
          }
        })
      },
      // 获取企业发展成果详情
      getCompanyDetailsData() {
        let self = this;
        let data = {
          source_type: self.companyDetails.selectedItem.length ? self.companyDetails.selectedItem[0] : '#',
        }

        console.log(self.companyDetails.selectedItem[0]);

        hlhttp.get({
          url:'datav_source/company_development_achievements',
          data: data,
          success(data){
            self.companyDetails.dvptAchievementsAmount1 = data.dvptAchievementsAmount1
            self.companyDetails.dvptAchievementsAmount2 = data.dvptAchievementsAmount2
            self.companyDetails.dvptAchievementsAmount3 = data.dvptAchievementsAmount3
          }
        })
      },
      changePlaceMesPageLimit(){
        this.getPlaceMesListData()
      },
      handlePlaceMesPage(num){
        this.getPlaceMesListData()
        this.getPlaceMesDetailsData()
      },
      changeAllOriginType(){
        this.isShowAllChange = true
      },
      closeAllChangePop(){
        this.isShowAllChange = false
      },
      confirmSelectAll(){
        const self = this
        let type = JSON.parse(JSON.stringify(this.selectedAllType))
        self.starProject.selectedStarProject = type
        self.placeMes.selectedPlaceMes = type
        self.investmentFinancing.selectedItem = type
        self.company.selectedItem = type
        self.companyDetails.selectedItem = type

        hlhttp.put({
          url:'datav_source/large_screen_data/global_switch',
          data: { 'source_type': type[0] },
          success(data){
            self.getStarProjectListData()
            self.getPlaceMesListData()
            self.getInvestmentDetailsData()
            self.getCompanyListData()
            self.getSmallTypeListData()
            self.getBigTypeListData()
            self.getCompanyDetailsData()
            self.isShowAllChange = false
            hl.toast('切换成功')
          }
        })
      },
      goConfig(){
        hlUrlUtil.goTo('lcDataScreenConfig', {ddtab:true})
      }

    },
    mounted:function () {
      hlSelectUi(false,false)

      this.getConfigDict()
      this.getActivityCenterDict()
    }
  })
}())
